{include file="public/layout" /}
<script type="text/javascript" src="__SKIN__/js/clipboard.min.js"></script>
<body class="eyou_body_xin">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
{include file="store/left" /}
<div id="geduan_div" class="h15"></div>
<div class="page" style="min-width:auto;margin-left:115px;padding-bottom: 15px;">
    <!-- <div class="fixed-bar">
        <div class="item-title mb0">
            <a class="back_xin" href="javascript:history.back();"  title="返回"><i class="iconfont e-fanhui"></i></a>
            <div class="subject">
                <h3>基础配置</h3>
                <h5></h5>
            </div>
        </div>
    </div> -->
    <form class="mt15" method="post" id="handlepost" action="{:url('Store/pc_conf')}" enctype="multipart/form-data" name="form1">
        <div class="ncap-form-default flexigrid htitx">
            <div class="hDiv"> <div class="hDivBox" style="height: 36px; padding-left: 10px; line-height: 36px;">商城设置</div> </div>
            
            <div id="div_web_status_close" class="{if condition='!isset($global.web_status) OR empty($global.web_status)'}none{/if}">
                <dl class="row">
                    <dt class="tit"> <label for="web_status_mode">&nbsp;</label> </dt>
                    <dd class="opt">
                        <label class="curpoin">
                            <input type="radio" name="web[web_status_mode]" value="0" {if condition='empty($global.web_status_mode)'}checked="checked"{/if}/>文案显示&nbsp;&nbsp;
                        </label>
                        <label class="curpoin">
                            <input type="radio" name="web[web_status_mode]" value="1" {if condition='!empty($global.web_status_mode) && 1 == $global.web_status_mode'}checked="checked"{/if}/>跳转链接&nbsp;&nbsp;
                        </label>
                        <label class="curpoin">
                            <input type="radio" name="web[web_status_mode]" value="2" {if condition='!empty($global.web_status_mode) && 2 == $global.web_status_mode'}checked="checked"{/if}/>模板页面&nbsp;&nbsp;
                        </label>
                    </dd>
                </dl>
                <dl class="row dl_web_status_mode {if condition='!empty($global.web_status_mode)'}none{/if}" id="dl_web_status_mode_0">
                    <dt class="tit"> <label for="web_status_text">&nbsp;</label> </dt>
                    <dd class="opt">
                        <input id="web_status_text" name="web[web_status_text]" value="{if condition='!isset($global.web_status_text)'}网站暂时关闭，维护中……{else /}{$global.web_status_text}{/if}" class="input-txt" type="text" autocomplete="off" />
                        <p class="notic"></p>
                    </dd>
                </dl>
                <dl class="row dl_web_status_mode {if condition='empty($global.web_status_mode) || 1 != $global.web_status_mode'}none{/if}" id="dl_web_status_mode_1">
                    <dt class="tit"> <label for="web_status_url">&nbsp;</label> </dt>
                    <dd class="opt">
                        <input id="web_status_url" name="web[web_status_url]" value="{$global.web_status_url|default=''}" class="input-txt" type="text" placeholder="关闭后，访问网站跳转的URL，http://" autocomplete="off"/>
                        <p class="notic">如果设置跳转URL，必须带有http:// 或 https://</p>
                    </dd>
                </dl>
                <dl class="row dl_web_status_mode {if condition='empty($global.web_status_mode) || 2 != $global.web_status_mode'}none{/if}" id="dl_web_status_mode_2">
                    <dt class="tit"> <label for="web_status_tpl">&nbsp;</label> </dt>
                    <dd class="opt">
                        <input id="web_status_tpl" name="web[web_status_tpl]" value="{$global.web_status_tpl|default=''}" class="input-txt" type="text" placeholder="关闭后，访问网站显示的自定义页面，public/close.html" autocomplete="off"/>
                        <p class="notic">静态模板路径前面不要带有子目录</p>
                    </dd>
                </dl>
            </div>
            <dl class="row">
                <dt class="tit"> <label for="web_logo">商城Logo</label> </dt>
                <dd class="opt">
                    <div class="input-file-show div_web_logo">
                        <span class="show">
                            <a id="img_a_web_logo" class="nyroModal" rel="gal" href="{$global.web_logo|default='javascript:void(0);'}" target="_blank">
                                <i id="img_i_web_logo" class="fa fa-picture-o" {notempty name="$global.web_logo"}onmouseover="layer_tips=layer.tips('<img src={$global.web_logo|default=''} class=\'layer_tips_img\'>',this,{tips: [1, '#fff']});"{/notempty} onmouseout="layer.close(layer_tips);"></i>
                            </a>
                        </span>
                        <span class="type-file-box">
                            <input type="text" id="web_logo" name="web[web_logo]" value="{$global.web_logo|default=''}" class="type-file-text" autocomplete="off">
                            <input type="button" name="button" id="button1" value="选择上传..." class="type-file-button">
                            <input class="type-file-file" onClick="GetUploadify(1,'','allimg','web_logo_img_call_back')" size="30" hidefocus="true" nc_type="change_site_logo" title="点击前方预览图可查看大图，点击按钮选择文件并提交表单后上传生效">
                        </span>
                    </div>
                    <p class="notic">默认网站LOGO，通用头部显示，显示尺寸以模板设计为主</p>
                </dd>
            </dl>
            <dl class="row none">
                <dt class="tit">
                    <label for="web_basehost">网站网址</label>
                </dt>
                <dd class="opt">
                    <input id="web_basehost" name="web[web_basehost]" value="{$global.web_basehost|default=''}" placeholder="{$Request.scheme}://" class="input-txt" type="text" />
                    <p class="notic"></p>
                </dd>
                <!-- {eq name="$web_cmsmode" value="2"}
                <dd class="variable">
                    <div><p>web_basehost</p></div>
                    <div class="r"><a href="javascript:void(0);" onclick="showtext('web_basehost');" class="ui-btn3 blue web_basehost" data-clipboard-text="{literal}{eyou:global name='web_basehost' /}{/literal}">复制标签</a></div>
                </dd>
                {/eq} -->
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="web_title">首页标题</label>
                </dt>
                <dd class="opt ui-web_title ui-text">
                    <input id="web_title" name="web[web_title]" value="{$global.web_title|default=''}" class="input-txt ui-input" type="text" data-num="80" />
                    <p class="notic">一般不超过80个字符</p>
                    <p class="ui-big-text none">一般不超过80个字符（<span class="ui-textTips">还可以输入80个字符</span>）</p>
                </dd>
                <!-- {eq name="$global.web_cmsmode" value="2"}
                <dd class="variable">
                    <div><p>web_title</p></div>
                    <div class="r"><a href="javascript:void(0);" onclick="showtext('web_title');" class="ui-btn3 blue web_title" data-clipboard-text="{literal}{eyou:global name='web_title' /}{/literal}">复制标签</a></div>
                </dd>
                {/eq} -->
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="web_keywords">首页关键词</label>
                </dt>
                <dd class="opt ui-keyword ui-text">
                    <input id="web_keywords" name="web[web_keywords]" value="{$global.web_keywords|default=''}" class="input-txt ui-input" type="text" data-num="100" />
                    <p class="notic">一般不超过100个字符</p>
                    <p class="ui-big-text none">一般不超过100个字符（<span class="ui-textTips">还可以输入100个字符</span>）</p>
                </dd>
                <!-- {eq name="$global.web_cmsmode" value="2"}
                <dd class="variable">
                    <div><p>web_keywords</p></div>
                    <div class="r"><a href="javascript:void(0);" onclick="showtext('web_keywords');" class="ui-btn3 blue web_keywords" data-clipboard-text="{literal}{eyou:global name='web_keywords' /}{/literal}">复制标签</a></div>
                </dd>
                {/eq} -->
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="web_description">首页描述</label>
                </dt>
                <dd class="opt ui-web_description ui-text">
                    <textarea rows="5" cols="60" id="web_description" name="web[web_description]" style="height:60px;" class="ui-input" data-num="200">{$global.web_description|default=''}</textarea>
                    <p class="notic">建议不超过200个字符</p>
                    <p class="ui-big-text none">建议不超过200个字符（<span class="ui-textTips">还可以输入200个字符</span>）</p>
                </dd>
                <!-- {eq name="$global.web_cmsmode" value="2"}
                <dd class="variable">
                    <div><p>web_description</p></div>
                    <div class="r"><a href="javascript:void(0);" onclick="showtext('web_description');" class="ui-btn3 blue web_description" data-clipboard-text="{literal}{eyou:global name='web_description' /}{/literal}">复制标签</a></div>
                </dd>
                {/eq} -->
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="web_copyright">版权信息</label>
                </dt>
                <dd class="opt">
                    <textarea cols="60" id="web_copyright" name="web[web_copyright]" class="h20">{$global.web_copyright|default=''}</textarea>
                    <p class="notic"></p>
                </dd>
                <!-- {eq name="$global.web_cmsmode" value="2"}
                <dd class="variable">
                    <div><p>web_copyright</p></div>
                    <div class="r"><a href="javascript:void(0);" onclick="showtext('web_copyright');" class="ui-btn3 blue web_copyright" data-clipboard-text="{literal}{eyou:global name='web_copyright' /}{/literal}">复制标签</a></div>
                </dd>
                {/eq} -->
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="web_recordnum">备案号</label>
                </dt>
                <dd class="opt ui-keyword">
                    {eq name='$global.web_recordnum_mode' value='1'}
                        <textarea rows="5" cols="60" id="web_recordnum" name="web[web_recordnum]" class="h40">{$global.web_recordnum|default=''}</textarea>
                    {else /}
                        <textarea rows="5" cols="60" id="web_recordnum" name="web[web_recordnum]" class="h20">{$global.web_recordnum|htmlspecialchars_decode|strip_tags}</textarea>
                    {/eq}
                    <input type="hidden" id="web_recordnum_mode" name="web_recordnum_mode" value="{$global.web_recordnum_mode|default='0'}">
                    &nbsp;[<a href="javascript:void(0);" onclick="show_recordnum(this);">{eq name='$global.web_recordnum_mode' value='
                    1'}普通模式{else /}代码模式{/eq}</a>]
                    <p class="notic"></p>
                </dd>
                <!-- {eq name="$global.web_cmsmode" value="2"}
                <dd class="variable">
                    <div><p>web_recordnum</p></div>
                    <div class="r"><a href="javascript:void(0);" onclick="showtext('web_recordnum');" class="ui-btn3 blue web_recordnum" data-clipboard-text="{literal}{eyou:global name='web_recordnum' /}{/literal}">复制标签</a></div>
                </dd>
                {/eq} -->
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label for="web_garecordnum">公安备案号</label>
                </dt>
                <dd class="opt ui-keyword">
                    {eq name='$global.web_garecordnum_mode' value='1'}
                        <textarea rows="5" cols="60" id="web_garecordnum" name="web[web_garecordnum]" class="h40">{$global.web_garecordnum|default=''}</textarea>
                    {else /}
                        <textarea rows="5" cols="60" id="web_garecordnum" name="web[web_garecordnum]" class="h20">{$global.web_garecordnum|htmlspecialchars_decode|strip_tags}</textarea>
                    {/eq}
                    <input type="hidden" id="web_garecordnum_mode" name="web_garecordnum_mode" value="{$global.web_garecordnum_mode|default='0'}">
                    &nbsp;[<a href="javascript:void(0);" onclick="show_garecordnum(this);">{eq name='$global.web_garecordnum_mode' value='
                    1'}普通模式{else /}代码模式{/eq}</a>]
                    <p class="notic"></p>
                </dd>
                <!-- {eq name="$global.web_cmsmode" value="2"}
                <dd class="variable">
                    <div><p>web_garecordnum</p></div>
                    <div class="r"><a href="javascript:void(0);" onclick="showtext('web_garecordnum');" class="ui-btn3 blue web_garecordnum" data-clipboard-text="{literal}{eyou:global name='web_garecordnum' /}{/literal}">复制标签</a></div>
                </dd>
                {/eq} -->
            </dl>
            <div class="bot"> <a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" onclick="formSubmit();">确认提交</a> </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    $(function() {
        tipsText();

        // 关闭站点
        $('input[name="web[web_status]"]').click(function(){
            $('#div_web_status_close').hide();
            if ($(this).val() == 1) {
                $('#div_web_status_close').show();
            }
        });

        $('input[name="web[web_status_mode]"]').click(function(){
            var web_status_mode = $(this).val();
            $('.dl_web_status_mode').hide();
            $('#dl_web_status_mode_'+web_status_mode).show();
        });
    });

    function formSubmit(){
        if($('input[name="web[web_status]"]:checked').val() == 1){
            var web_status_mode = $('input[name="web[web_status_mode]"]:checked').val();
            if(web_status_mode == 1){
                if ($.trim($('input[name="web[web_status_url]"]').val()) == '') {
                    showErrorMsg('跳转的URL不能为空！');
                    $('input[name="web[web_status_url]"]').focus();
                    return false;
                } else if (!checkURL($('input[name="web[web_status_url]"]').val())) {
                    showErrorMsg('跳转的URL格式不正确！');
                    $('input[name="web[web_status_url]"]').focus();
                    return false;
                }
            }
        }
        layer_loading('正在处理');
        $.ajax({
            type : 'post',
            url : "{:url('Store/pc_conf', ['_ajax'=>1])}",
            data : $('#handlepost').serialize(),
            dataType : 'json',
            success : function(res){
                layer.closeAll();
                if(res.code == 1){
                    layer.msg(res.msg, {time: 1000}, function(){
                        window.location.reload();
                    });
                }else{
                    showErrorMsg(res.msg);
                }
            },
            error: function(e){
                layer.closeAll();
                showErrorAlert(e.responseText);
            }
        });
    }

    function showtext(classname){
        var clipboard1 = new Clipboard("."+classname);clipboard1.on("success", function(e) {layer.msg("复制成功");});clipboard1.on("error", function(e) {layer.msg("复制失败！请手动复制", {icon:5});}); 
    }

    //网站logo 回调
    function web_logo_img_call_back(fileurl_tmp)
    {
        $("#web_logo").val(fileurl_tmp);
        $("#img_a_web_logo").attr('href', fileurl_tmp);
        $("#img_i_web_logo").attr('onmouseover', "layer_tips=layer.tips('<img src="+fileurl_tmp+" class=\\'layer_tips_img\\'>',this,{tips: [1, '#fff']});");
    }
    
    function show_recordnum(obj)
    {
        var recordnumObj = $('#web_recordnum');
        var value = recordnumObj.val();
        var valuehtml = "";

        if (value.indexOf('&lt;/a&gt;') == -1) {
            valuehtml = '<a href="https://beian.miit.gov.cn/" rel="nofollow" target="_blank">'+value+'</a>';
        }

        var web_recordnum_mode = $('#web_recordnum_mode').val();
        if (web_recordnum_mode == 0) { // 切换为代码模式
            $('#web_recordnum_mode').val(1);
            $(obj).html('普通模式');
            recordnumObj.css('height', '40px');
            recordnumObj.val(valuehtml);
        } else { // 切换为普通模式
            $('#web_recordnum_mode').val(0);
            $(obj).html('代码模式');
            recordnumObj.css('height', '20px');
            recordnumObj.val(removeHTMLTag(value));
        }
    }
    
    function show_garecordnum(obj)
    {
        var gaRecordnumObj = $('#web_garecordnum');
        var value = gaRecordnumObj.val();
        var valuehtml = "";

        if (value.indexOf('&lt;/a&gt;') == -1) {
            var recordcode = value.replace(/([^\d\-]+)/g, '');
            valuehtml = '<a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode='+recordcode+'" rel="nofollow" target="_blank">'+value+'</a>';
        }

        var web_garecordnum_mode = $('#web_garecordnum_mode').val();
        if (web_garecordnum_mode == 0) { // 切换为代码模式
            $('#web_garecordnum_mode').val(1);
            $(obj).html('普通模式');
            gaRecordnumObj.css('height', '40px');
            gaRecordnumObj.val(valuehtml);
        } else { // 切换为普通模式
            $('#web_garecordnum_mode').val(0);
            $(obj).html('代码模式');
            gaRecordnumObj.css('height', '20px');
            gaRecordnumObj.val(removeHTMLTag(value));
        }
    }

    //过滤HTML标签
    function removeHTMLTag(str) {
        str = str.replace(/<\/?[^>]*>/g, ''); //去除HTML tag
        str = str.replace(/[ | ]*\n/g, '\n'); //去除行尾空白
        str = str.replace(/ /ig, ''); //去掉 
        return str;
    }

</script>

{include file="public/footer" /}
